#include <vector>
#include <deque>
#include <string.h>
#include <algorithm>
#include <iostream>
using namespace std;

class Person{
public:
    Person(char * name, int sorce = 0)
    :_name(new char[strlen(name) + 1]())
    ,_socre(sorce)
    {   
        strcpy(_name,name);
    }

    char * _name;
    int _socre;
};

int avg(deque<int> & gread){
    int sum = 0; 
    for(auto & ele : gread){
        sum += ele;
    }
    sum /= 10;
    return sum;
}

void test(){

    // 选手vector
    // 1.创建Person类将选手放入vector中
    vector<Person> athlete;
    athlete.push_back("A");
    athlete.push_back("B");
    athlete.push_back("C");
    athlete.push_back("D");
    athlete.push_back("E");
    // 初始化ABCDE五个选手的名称，成绩初始为0

    // 评委deque
    // 2.把评委打的分数放入deque中并排序
    deque<int> gread;
    for(int i = 0; i < athlete.size(); i++){
        gread.clear();
        cout << "请评委们给" << athlete[i]._name <<"选手打分" << endl;
        for(int i = 0;  i < 10; i ++){
                int x;
                cin >> x;
                gread.push_back(x);
        }
        // 将分数进行排序
        sort(gread.begin(),gread.end());
        // 去掉最高分和最低分
        gread.pop_back();
        gread.pop_front();
        // 3.deque变量计算平均值
        int avg_gread = avg(gread);
        athlete[i]._socre = avg_gread;
    }

    for(int i = 0; i < athlete.size(); i++){
        cout << "_name = " << athlete[i]._name <<
             " _sorce = "<< athlete[i]._socre << endl;
    }

}

int main(int atgc, char * argv[])
{
    test();
    return 0;
}

